package yunquan.wang.base.config;

import java.util.Properties;

import org.jbpm.task.service.UserGroupCallbackManager;
import org.springframework.web.util.WebUtils;

/**
 * 应用配置
 * 
 * @author Administrator=
 * 
 */
public class AppConfig {
	public static final String DB_RESTORE_SQL="dbrestore";
	private static String WEBAPP_ROOT = null;// WEB根目录
	private static String CLASS_ROOT = null;// Class根目录
	private static Integer DEFAULT_PAGENUMBER;// 默认显示的每页条数
	private static String MYSQL_HOME = "";// MYSQL的路径
	private static String DATABASE;// 数据库名称
	private static String DATABASE_URL;// 数据库地址
	private static String DATABASE_USERNAME;// 用户名
	private static String DATABASE_PASSWORD;// 密码
	private static String DATABASE_PORT;// 数据库端口
	private static String [] BACKUP_IGNORE_TABLE;// 备份时忽略的表
	private static String BACKUP_DATA_DIR;// 备份数据库文件路径
	private static String REPORT_TEMPLATE_PATH;// 报表文件路径
	
	public static int DISPLAY_PAGE_NO=20;//每页数量
	public static int MESSAGE_SHOW_TIME=300;//消息显示的时间
	public static void setApplicationPorperties(Properties porperties) {
		DATABASE=porperties.getProperty("database.name");
		DATABASE_URL=porperties.getProperty("database.host");
		DATABASE_PORT=porperties.getProperty("database.port");
		DATABASE_USERNAME=porperties.getProperty("database.username");
		DATABASE_PASSWORD=porperties.getProperty("database.password");
		BACKUP_DATA_DIR=porperties.getProperty("database.backdir");
		BACKUP_IGNORE_TABLE=porperties.getProperty("database.backupignor").split(",");
		DEFAULT_PAGENUMBER = Integer.valueOf(porperties
				.getProperty("page.default"));
		//JBPM propertys
		
		//System.setProperty(UserGroupCallbackManager.USER_GROUP_CALLBACK_KEY, "yunquan.wang.base.process.DefaultUserGroupCallbackImpl");
		System.setProperty(UserGroupCallbackManager.USER_GROUP_CALLBACK_KEY, "org.jbpm.task.service.DefaultUserGroupCallbackImpl");
	}

	public static String getWebrootPath() {
		return WEBAPP_ROOT;
	}

	public static String getclasspath() {
		return CLASS_ROOT;
	}

	public static Integer getPagesize() {
		return DEFAULT_PAGENUMBER;
	}

	public static String getMysqlhome() {
		return MYSQL_HOME;
	}

	public static String getDatabase() {
		return DATABASE;
	}

	public static String getDbUser() {
		return DATABASE_USERNAME;
	}

	public static String getDbPass() {
		return DATABASE_PASSWORD;
	}

	public static String getDbhost() {
		return DATABASE_URL;
	}

	public static Integer getDbport() {
		return Integer.valueOf(DATABASE_PORT);
	}
    
	
	public static String[] getDbBackIgnore()
	{
	return	BACKUP_IGNORE_TABLE;
	}
	
	public static String reportFilePath()
	{
		return REPORT_TEMPLATE_PATH;
	}
	
	public static String getBackDbFilePath()
	{
		return getWebContainerPath()+BACKUP_DATA_DIR;
	}
	
	public static String getWebContainerPath()
	{
		 
		return System.getProperty(WebUtils.DEFAULT_WEB_APP_ROOT_KEY);
	 
	}
	
	public static boolean isWindows() {
		return false;
	}
	

}
